export const getters = {
    // 流量计费
    businessId: state => state.flow.businessId,
    accStatus: state => state.flow.accStatus,
    flowQueryData: state => state.flow.flowQueryData,
    showFlowAlert: state => state.flow.showFlowAlert,
    dateType:state => state.flow.dateType,
    keepLiveArr:state => state.flow.keepLiveArr,
    stepIndex: state => state.common.stepIndex,
    valid_step1: (state) => {
        let openType = state.merchant.openType;
        let merchantType = state.merchant.merchantType;
        // 企业/个体
        let type1 = {
            openType: state.merchant.openType,
            merchantType: state.merchant.merchantType,
            mcc: state.merchant.mcc,
            bizStartTime: state.merchant.bizStartTime,
            bizEndTime: state.merchant.bizEndTime,
            legalStartTime: state.merchant.legalStartTime,
            legalEndTime: state.merchant.legalEndTime,
            //bizAreaId: state.merchant.bizAreaId.length > 0 ? '1' : '',
            merchantFullName: state.merchant.merchantFullName,
            merchantAbbrName: state.merchant.merchantAbbrName,
            bizLicense: state.merchant.bizLicense,
            merchantAddress: state.merchant.merchantAddress,
            bizScope: state.merchant.bizScope,
            legalName: state.merchant.legalName,
            legalIdcard: state.merchant.legalIdcard,
            legalIdcardAddress: state.merchant.legalIdcardAddress,
            bizImg: state.merchant.bizImg,
            legalFontImg: state.merchant.legalFontImg,
            legalBackImg: state.merchant.legalBackImg,
            legalHandFontImg: state.merchant.legalHandFontImg,
        }
        console.log('type1',type1)
        // 小微
        let type2 = {
            openType: state.merchant.openType,
            merchantType: state.merchant.merchantType,
            mcc: state.merchant.mcc,
            bizAreaId: state.merchant.bizAreaId.length > 0 ? '1' : '',
            merchantFullName: state.merchant.merchantFullName,
            merchantAbbrName: state.merchant.merchantAbbrName,
            merchantAddress: state.merchant.merchantAddress,
            bizScope: state.merchant.bizScope,
        }
        // 直营连锁
        let type3 = {
            openType: state.merchant.openType,
            bizAreaId: state.merchant.bizAreaId.length > 0 ? '1' : '',
            merchantFullName: state.merchant.merchantFullName,
            merchantAbbrName: state.merchant.merchantAbbrName,
            merchantAddress: state.merchant.merchantAddress,
        }
        console.log(type3);
        let dataArr = [];
        if (openType == 1) {
            for (let key in type3) {
                if (!type3[key]) {
                    console.log(type3[key]);
                    dataArr.push(type3[key])
                }
            }
        }
        if ((openType == 2 && state.merchant.merchantType == 1) ||
            (openType == 2 && state.merchant.merchantType == 2)) {
            for (let key in type1) {
                if (!type1[key]) {
                    dataArr.push(type1[key])
                }
            }
        }
        if (openType == 2 && state.merchant.merchantType == 3) {
            for (let key in type2) {
                if (!type2[key]) {
                    dataArr.push(type2[key])
                }
            }
        }
        if (!openType) {
            dataArr.push('')
        }
        if (openType == 2 && !merchantType) {
            dataArr.push('')
        }
        if (dataArr.length == 0) {
            return state.merchant.no_step1
        } else {
            return state.merchant.is_step1
        }
    },
    valid_step2: (state) => {
        let dataArr = [];
        let openType = state.merchant.openType; //分店类型
        let storeType = state.merchant.merchantType;
        let storeAccountType = state.settlement.acconutType;
        let info1 = {
            openPermissionImg: state.settlement.openPermissionImg,
            accountName1: state.settlement.accountName1,
            accountNum1: state.settlement.accountNum1,
            bankId1: state.settlement.bankId1,
            acconutArea1: state.settlement.acconutArea1.length > 0 ? '1' : '',
            branchBankId1: state.settlement.branchBankId1,
            accountMobile1: state.settlement.accountMobile1
        };
        let info2 = {
            settleFontImg: state.settlement.settleFontImg,
            settleBackImg: state.settlement.settleBackImg,
            settleHandFontImg: state.settlement.settleHandFontImg,
            settlementName: state.settlement.settlementName,
            settlementNum: state.settlement.settlementNum,
            idCardStartTime: state.settlement.idCardStartTime,
            idCardEndTime: state.settlement.idCardEndTime
        };
        let info3 = {
            bankCardImg: state.settlement.bankCardImg,
            bankCard2Img: state.settlement.bankCard2Img,
            accountName2: state.settlement.accountName2,
            accountNum2: state.settlement.accountNum2,
            bankId2: state.settlement.bankId2,
            acconutArea2: state.settlement.acconutArea2.length > 0 ? '1' : '',
            branchBankId2: state.settlement.branchBankId2,
            accountMobile2: state.settlement.accountMobile2
        };
        let type1 = Object.assign({}, info1);
        let type2 = Object.assign({}, info1, info3);
        let type3 = Object.assign({}, info1, info2, info3);
        let type4 = Object.assign({}, info3);
        let type5 = Object.assign({}, info2, info3);
        if(storeAccountType != 1){
            [type2 ,type3 , type4 ,type5].map(v => {
              delete v.branchBankId2
              delete v.acconutArea2
              delete v.acconutArea1
              delete v.branchBankId1
            })
          }
        if (openType == 2) {
            if (storeType == 1 && storeAccountType == 1) {
                // 企业法人对公
                for (let key in type1) {
                    if (!type1[key]) {
                        dataArr.push(type1[key])
                    }
                }
            } else if (storeType == 1 && storeAccountType == 2) {
                // 企业法人对私
                for (let key in type2) {
                    if (!type2[key]) {
                        dataArr.push(type2[key])
                    }
                }

            } else if (storeType == 1 && storeAccountType == 3) {
                // 企业非法人对私
                for (let key in type3) {
                    if (!type3[key]) {
                        dataArr.push(type3[key])
                    }
                }
            } else if (storeType == 2 && storeAccountType == 2) {
                // 个体对私
                for (let key in type4) {
                    if (!type4[key]) {
                        dataArr.push(type4[key])
                    }
                }
            } else if ((storeType == 3 && storeAccountType == 2) || (storeType == 2 && storeAccountType == 3)) {
                // 小微 或者 个体非法人对私
                for (let key in type5) {
                    if (!type5[key]) {
                        dataArr.push(type5[key])
                    }
                }

            }
        }
        if (!storeAccountType) {
            dataArr.push('')
        }
        if (dataArr.length == 0) {
            return state.settlement.no_step2
        } else {
            return state.settlement.is_step2
        }
    },
    valid_step3: (state) => {
        let dataArr = [];
        let type1 = {
            payType: state.merchant.payType,
            firstSettleType:state.merchant.firstSettleType,
            // rate_d0: state.merchant.rate_d0,
            // rate_fd: state.merchant.rate_fd,
            // rate_sk: state.merchant.rate_sk,
            // rate_sm: state.merchant.rate_sm,
        };
        let type2 = {
            payType: state.merchant.payType,
            equipmentSN: state.merchant.equipmentSN,
            firstSettleType:state.merchant.firstSettleType,
        };
        if (state.merchant.payType == 1) {
            for (let key in type1) {
                if (!type1[key]) {
                    dataArr.push(type1[key])
                }
            }
        }
        if (state.merchant.payType == 2) {
            for (let key in type2) {
                if (!type2[key]) {
                    dataArr.push(type2[key])
                }
            }
        }
        if (!state.merchant.payType) {
            dataArr.push('')
        }

        if (dataArr.length == 0) {
            return state.merchant.no_step3
        } else {
            return state.merchant.is_step3
        }
    },
    valid_step4: (state) => {
        let dataArr = [];
        let type1 = {
            storeAddressImg: state.merchant.storeAddressImg,
            storeDoorImg: state.merchant.storeDoorImg,
            cashierImg:state.merchant.cashierImg,
        };
        let type2 = {
            storeAddressImg: state.merchant.storeAddressImg,
            storeDoorImg: state.merchant.storeDoorImg,
            proofImg: state.merchant.proofImg,
            cashierImg:state.merchant.cashierImg,
        };
        if (state.merchant.openType == 1) {
            for (let key in type1) {
                if (!type1[key]) {
                    dataArr.push(type1[key])
                }
            }
        } else if (state.merchant.openType != 1) {
            let acconutType = state.settlement.acconutType
            if (acconutType == 3) {
                for (let key in type2) {
                    if (!type2[key]) {
                        dataArr.push(type2[key])
                    }
                }
            } else if (acconutType == 1 || acconutType == 2) {
                for (let key in type1) {
                    if (!type1[key]) {
                        dataArr.push(type1[key])
                    }
                }
            }
        }
        if (dataArr.length == 0) {
            return state.merchant.no_step4
        } else {
            return state.merchant.is_step4
        }
    },
    valid_account:(state)=>{
      let dataArr = [];
      let type={
        accountFontImg:state.merchant.accountFontImg,
        accountBackImg:state.merchant.accountBackImg,
        accountUserName:state.merchant.accountUserName,
        accountStartTime:state.merchant.accountStartTime,
        accountEndTime:state.merchant.accountEndTime,
        accountCardImg:state.settlement.accountCardImg,
        bankCardNo:state.settlement.bankCardNo,
        bankIdHoText:state.settlement.bankIdHoText,
        acconutArea3Text:state.settlement.acconutArea3Text,
        bankIdText:state.settlement.bankIdText,
        bankId:state.settlement.bankId,
        bankAccountMobile:state.settlement.bankAccountMobile
      }
      for (let key in type) {
        if (!type[key]) {
            dataArr.push(type[key])
        }
      }
      console.log('type',type)
      if (dataArr.length == 0) {
        return state.merchant.no_account
    } else {
        return state.merchant.is_account
    }
    }
}